package com.ct.gd.passport.view.weather.util;

import com.ct.gd.passport.R;

/***
 * 天气和资源的转换
 * 
 * 目前只收集到下面的天气类型，有更多时可以添加
 * @author Administrator
 *
 */
public class SinaWeatherUtil {
	
	public static final int[] WEATHER_RESOURCE = {
		R.drawable.unknow,
		R.drawable.qing,
		R.drawable.yin,
		R.drawable.duoyun,
		R.drawable.xiaoyu,
		R.drawable.zhongyu,
		R.drawable.dayu,
		R.drawable.zhenyu,
		R.drawable.leizhenyu,
		R.drawable.baoyu,
		R.drawable.xue
	};
	
	public static final int[] WEATHER_RESOURCE_LARGE = {
		R.drawable.unknow_l,
		R.drawable.qing_l,
		R.drawable.yin_l,
		R.drawable.duoyun_l,
		R.drawable.xiaoyu_l,
		R.drawable.zhongyu_l,
		R.drawable.dayu_l,
		R.drawable.zhenyu_l,
		R.drawable.leizhenyu_l,
		R.drawable.baoyu_l,
		R.drawable.xue_l
	};
	
	public static final String[] WEATHER_TYPES = {
		"",
		"qing",
		"yin",
		"duoyun",
		"xiaoyu",
		"zhongyu",
		"dayu",
		"zhenyu",
		"leizhenyu",
		"baoyu",
		"xue"		// 9
	};
	
	/**
	 * 根据拼音获取天气类型id
	 * @param spell
	 * @return
	 */
	public static final int getWeatherType(String spell){
		if(spell.indexOf("xue")>=0){
			return 9;
		}else{
			for(int i=WEATHER_TYPES.length;--i>=0;){
				if(WEATHER_TYPES[i].equals(spell)){
					return i;
				}
			}
		}
		return 0; // 未知的天气
	}
	
	/**
	 * 根据拼音获取天气类型的图片资源id
	 * @param spell
	 * @return
	 */
	public static final int getWeatherResource(String spell,boolean large){
		int type = getWeatherType(spell);
		return large?WEATHER_RESOURCE_LARGE[type]:WEATHER_RESOURCE[type];
	}
	
}
